import { get, post } from "@/utils/request"

export default {
    namespaced: true,
    state: {
        hospitals: []
    },
    mutations: {
        refreshQueryHospitals(state,data) {
            state.hospitals = data
        }
    },
    actions: {
        // 删除
        async deleteHospital({dispatch},id) {
            let res = await get("/hospital/deleteById",{id});
            return res;
        },
        // 保存
        async saveOrUpdateHospital({dispatch},params) {
            let res = await post("/hospital/saveOrUpdate",params);
            return res
        },
        // 分页查询所有医院
        async queryHospitals({commit},params) {
            let res = await get("/hospital/pageQuery",params);
            commit("refreshQueryHospitals",res.data)
        }
    }
}